The RollupIterator object contains the following methods:
The Initialize method initializes the rollup iterator.
Initialize(VhsSiteService As String, TagString As String, TimeStampEarliest As Date, TimeStampLatest As Date, RollupType As Integer, RollupUnits As Integer, RollupPeriod As Integer, TopOfDayHour As Integer) As Long
| Parameter | Required | Description |
|---|---|---|
|
VhsSiteService |
Yes |
The site and service name of the VHS point tag, in "site.service" format. |
|
TagString |
Yes |
The point tag from which data is being retrieved in valid CygNet tag string format. |
|
TimeStampEarliest |
Yes |
The starting date of the retrieval period. This field must be a valid date/time (not 0). |
|
TimeStampLatest |
Yes |
The ending date of the retrieval period. Enter 0 for the date of the latest timestamp. |
|
RollupType |
Yes |
Sets the value entry rollup type. The possible values are listed on the CxRollupType table. |
|
RollupUnits |
Yes |
Sets the rollup units. This refers to time increments, such as seconds, minutes, hours, or days. The possible values are listed on the CxRollupUnits table. |
|
RollupPeriod |
Yes |
Sets the rollup period. Rollup period refers to the quantity of units in a period. For example, to rollup 30 days, the RollupPeriod is 30 and the RollupUnit is "days." |
|
TopOfDayHour |
Yes |
The offset value to use if the subunit to the major unit (i.e. hours to a day) does not start at the time unit expected. For example, to accommodate contract days starting at 5 AM, the TopOfDayHour would be 5 (indicating 5 hours from midnight). |
Returns a value based on whether the initialization was successful or not (1 = Success; 0 = Failure). The cursor is placed at the first (earliest) value by default.
Example
The following method displays a day’s worth of maximum values, calculated every half hour. This is accomplished using a rollup type CalcMax (4), rollup unit Minutes (1), and a rollup period of 30. The point name and date are accepted as parameters.
|
Usage: DisplayDailyMaxs "CYGDEMO.UIS:POINT1", "5/24/2004"
Sub DisplayDailyMaxs (tagString, curDay) Dim vhsRollupIter, histEntry lstValues.ResetContent
Set vhsRollupIter = CreateObject("CxVhsLib.RollupIterator") Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
'Initialize rollup iterator vhsRollupIter.Initialize "CYGDEMO.VHS", tagString, CStr(curDay),_ CStr(curDay) & " 23:59:59", 4, 1, 30, 0 vhsRollupIter.MoveFirst
'Show all max values in a list box While (vhsRollupIter.GetForward(histEntry)) lstValues.AddString CStr(histEntry.TimeStamp) & " "_ & CStr(histEntry.Value) Wend End Sub |
The GetForward method retrieves information about the next value in the iteration list. Returns a HistoryEntryEx object in the pVal variable.
GetForward(pVal As Variant) As Long
| Parameter | Required | Description |
|---|---|---|
|
pVal |
Yes |
Returns the timestamp, status, user status, and value of a record. Type: HistoryEntryEx |
The GetForward function retrieves information for the next value and moves the cursor forward to the value. Returns 0 until TimeStampLatest is reached.
Example
See RollupIterator.Initialize for example.
The GetForwardEx method retrieves information about the next value in the iteration list. Returns a ValueEntryEx object in the pVal variable.
GetForwardEx(pVal As Variant) As Long
| Parameter | Required | Description |
|---|---|---|
|
pVal |
Yes |
Returns the timestamp, status, user status, value, time ordinal, and rollup information for the value entry. Type: ValueEntryEx |
The GetForwardEx function retrieves information for the next value and moves the cursor forward to the value. Returns 0 until TimeStampLatest is reached. This method is identical to GetForward, except that the value is returned as a ValueEntryEx object rather than a HistoryEntryEx object.
Example
The following method displays a day’s worth of maximum values, calculated every half hour. This is accomplished using a rollup type CalcMax (4), rollup unit Minutes (1), and a rollup period of 30.
|
Sub DisplayDailyMaxsEx () Dim vhsRollupIter, valEntry, tag lstValues.ResetContent
Set vhsRollupIter = CreateObject("CxVhsLib.RollupIterator") Set valEntry = CreateObject("CxVhsLib.ValueEntryEx") tag = "CYGDEMO.UIS:POINT1"
'Initialize rollup iterator vhsRollupIter.Initialize "CYGDEMO.VHS", tag, Now,_ Now & " 23:59:59", 4, 1, 30, 0 vhsRollupIter.MoveFirst
'Show all max values in a list box While (vhsRollupIter.GetForwardEx(valEntry)) lstValues.AddString CStr(valEntry.TimeStamp) & " "_ & CStr(valEntry.Value) Wend End Sub |
The MoveFirst method moves to the first value in the iteration list.
MoveFirst() As Long
Returns a value based on whether the initialization was successful or not (1 = Success; 0 = Failure).
Example
See RollupIterator.Initialize for example.